package com.joplus.housekeeper.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Administrator on 2016/12/19.
 */

public class ChatInsertMessage implements Parcelable {

    public static enum InsertMessageType{
        FrontMessage,//app前台消息
        FrontAndServerMessage,//前台和服务器都有的消息
        ServerMessage//后台消息
    }

    InsertMessageType type;
    String frontMessage;
    String serverMessage;


    public ChatInsertMessage(InsertMessageType type, String message) {
        this.type = type;
        this.frontMessage = message;
        this.serverMessage=message;
    }

    public ChatInsertMessage(String frontMessage, String serverMessage) {
        this.frontMessage = frontMessage;
        this.serverMessage = serverMessage;
        type=InsertMessageType.FrontAndServerMessage;
    }

    public InsertMessageType getType() {
        return type;
    }

    public void setType(InsertMessageType type) {
        this.type = type;
    }

    public String getFrontMessage() {
        return frontMessage;
    }

    public void setFrontMessage(String frontMessage) {
        this.frontMessage = frontMessage;
    }

    public String getServerMessage() {
        return serverMessage;
    }

    public void setServerMessage(String serverMessage) {
        this.serverMessage = serverMessage;
    }

    @Override
    public String toString() {
        return super.toString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.type == null ? -1 : this.type.ordinal());
        dest.writeString(this.frontMessage);
        dest.writeString(this.serverMessage);
    }

    protected ChatInsertMessage(Parcel in) {
        int tmpType = in.readInt();
        this.type = tmpType == -1 ? null : InsertMessageType.values()[tmpType];
        this.frontMessage = in.readString();
        this.serverMessage = in.readString();
    }

    public static final Parcelable.Creator<ChatInsertMessage> CREATOR = new Parcelable.Creator<ChatInsertMessage>() {
        @Override
        public ChatInsertMessage createFromParcel(Parcel source) {
            return new ChatInsertMessage(source);
        }

        @Override
        public ChatInsertMessage[] newArray(int size) {
            return new ChatInsertMessage[size];
        }
    };
}